import { defineStore } from "pinia";
import { ref } from "vue";

export const useUserStore = defineStore('user',() => {
  const userInfo = ref({})
  const username = ref()
  const setUserInfo = (val) => {
    userInfo.value = val
  }
  const setUserName = (val) => {
    username.value = val
  }
  const clearUserInfo = () => {
    userInfo.value = undefined
    username.value = undefined
  }
  return{
    userInfo,
    username,
    setUserInfo,
    setUserName,
    clearUserInfo,
  }
},
{
persist: {
  storage: {
    getItem(key) {
      return uni.getStorageSync(key)
    },
    setItem(key, value) {
      uni.setStorageSync(key, value)
    },
  },
},
},
)